package com.collect.senegal.zhiAdater.zhiWhatsapp;

import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.collect.senegal.R;
import com.collect.senegal.zhiBean.zhiReceive.ZHIRCustomerWhatsAppAccountFollow;
import com.collect.senegal.zhiGlobal.zhiAppSettings.ZHIProjectConfigs;
import com.collect.senegal.zhiHelper.ZHISysShareHelper;

public class ZHIWhatsappAdjuster extends BaseQuickAdapter<ZHIRCustomerWhatsAppAccountFollow, BaseViewHolder> {

    public ZHIWhatsappAdjuster() {
        super(R.layout.item_whatsapp_follow_list, null);
    }

    private ZHIWhatsappAdjusterClickListener mOnCTCustomerOrderAdjusterItemClickListener;

    @Override
    protected void convert(BaseViewHolder helper, ZHIRCustomerWhatsAppAccountFollow item) {
        helper.setText(R.id.tv_orderId, item.getOrderId());
        helper.setText(R.id.tv_mobile, item.getWhatsAppAccountEncryptFormatter());
        helper.setText(R.id.tv_product, item.getProduct());

        helper.setVisible(R.id.tv_remark, !TextUtils.isEmpty(item.getRemark()));
        helper.setText(R.id.tv_remark, mContext.getString(R.string.remark_flag) + item.getRemark());

        if (mOnCTCustomerOrderAdjusterItemClickListener != null) {
            helper.getView(R.id.tv_follow).setOnClickListener(view -> mOnCTCustomerOrderAdjusterItemClickListener.OnItemClick(item));
        }

        if(!TextUtils.isEmpty(item.getWhatsAppAccount())) {
            helper.getView(R.id.iv_whatsapp).setOnClickListener(v -> ZHISysShareHelper.sendMsgWithWhatsApp(mContext, ZHIProjectConfigs.PRE_PHONE + item.getWhatsAppAccount(), item.getActiveUrl()));
        }

    }

    public void setZHIWhatsappAdjusterClickListener(ZHIWhatsappAdjusterClickListener whatsappAdjusterClickListener) {
        this.mOnCTCustomerOrderAdjusterItemClickListener = whatsappAdjusterClickListener;
    }

}
